package cc.rengu.redp.hawk.job;

import cc.rengu.redp.job.domain.Job;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.springframework.scheduling.quartz.QuartzJobBean;

/**
 * 定时任务
 */
@Slf4j
public class ScheduleQuietJob extends QuartzJobBean {

    @Override
    protected void executeInternal(JobExecutionContext context) {
        Job scheduleJob = (Job) context.getMergedJobDataMap().get(Job.JOB_PARAM_KEY);
        try {
            // 执行任务
            HawkPullJob hawkPullJob = new HawkPullJob(scheduleJob.getMethodName(), scheduleJob.getParams());
            hawkPullJob.run();
        } catch (Exception e) {
            log.error("任务执行失败，任务ID：" + scheduleJob.getJobId(), e);
        }
    }
}
